package org.openanypcao.cs.core;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * 
 *作者：曹正标</p>
 *日期：2011-12-29</p>
 *功能：通用常量定义</p>
 *序列号</p>
 */
public class GeneralConstant {
	
	/**默认编码格式:UTF-8*/
	public static final String DEFAULT_ENCODE = "UTF-8";
	
	/**默认连接超时时间：5秒*/
	public static final int DEFAULT_CONNECT_TIMEOUT = 50000;
	
	/**默认数据读取超时时间:5秒*/
	public static final int DEFAULT_READ_TIMEOUT = 50000;
	
	/**账号*/
	public static String ACCOUNT = "";
	
	/**密码*/
	public static String PASSWORD = "";
	
	/**服务器地址+工作空间*/
	public static String HOST_URL = "";
	
	public static Map<String, String> courseIdMap = new HashMap<String, String>();

	
	/**
	 * 初始化properties配置文件
	 */
	static {
		Logger logger = LogManager.getLogger(GeneralConstant.class);
		Properties properties = new Properties();
		try {
			InputStream is = GeneralConstant.class.getClassLoader().getResourceAsStream("cs_connection_default.properties");
			if(is != null){
				logger.log(Level.INFO, "cs_connection.properties is loading success!");
			}else{
				is = GeneralConstant.class.getClassLoader().getResourceAsStream("cs_connection_default.properties");
				logger.log(Level.INFO, "cs_connection.properties properties is loading faild, use cs_connection_default.properties!");
			}
			properties.load(is);
			HOST_URL = properties.getProperty("host.url");
		} catch (IOException e) {
			logger.log(Level.SEVERE, e.getLocalizedMessage());
		}
		//www.owvlab.net里的课程ID，教务人员的课程库
		courseIdMap.put("owvlabjava", "ff80808137915a1001379bbe18f42c25");//java课程
		courseIdMap.put("owvlabcnsl", "8ae4adb93c479f1d013d346656e7051e");//网络安全
		courseIdMap.put("owvlabcns", "ff80808136cdbe4f0136cdc51858005a");//技能大赛
		courseIdMap.put("owvlabcs", "ff80808137b5229c0137b6361b1404d9");//通信原理
		
		//192.168.199.151里的课程ID，教务人员的课程库(发布客户时使用)
//		courseIdMap.put("owvlabjava", "402847173869ad9301388f0435be047f");//Java程序设计
//		courseIdMap.put("owvlabcnsl", "402847173b1613b6013b25f27e970076");//计算机网络安全
//		courseIdMap.put("owvlabcns", "402847173846e53e013854e6e743063a");//计算机网络技能大赛
//		courseIdMap.put("owvlabcs", "40284717326b52bd01326fad04bd00a4");//通信原理
		
		
	}
}
